package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface CartMapper {
    /**
     * 根据菜品ID/套餐ID/口味 查询我的购物车数据
     * @return
     */
    public List<ShoppingCart> findByQuery(ShoppingCart shoppingCart);

    /**
     * 保存购物车
     * @param shoppingCart
     */
    public void insert(ShoppingCart shoppingCart);

    /**
     * 根据ID修改购物车菜品数量
     * @param shoppingCart
     */
    public void updateNumberById(ShoppingCart shoppingCart);


    void deleteByQuery(ShoppingCart shoppingCart);

    /**
     * 根据用户id删除购物车数据
     *
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);
}
